﻿using BySoft.Server.Common;
using BySoft.Server.Common.Entity;
using BySoft.Server.DataAccess;
using BySoft.Server.DataAccess.UserCode;
using OneSoft.DataAccess;
using OneSoft.EntityCore;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace BySoft.Server.Business
{
    public partial class BsOutorder
    {

        public static bool CheckExist(string OutorderIDValue)
        {

            return ClsComm.CheckExist("BS_Outorder", "BillID", OutorderIDValue, true);
           
        }
        public static bool CheckUsed(string BillIDValue)
        {
            // return

            bool result = ClsComm.CheckExist("BS_OutBackMat", "OutOrderID", BillIDValue, true);
            result =result || ClsComm.CheckExist("BS_OutMatReturn", "OutOrderID", BillIDValue, true);
            return result;

        }
        public static bool SaveOrUpdate(BsOutorderEntity entity, DataTable OutorderDetailDT, bool isNew)
        {
            return BsOutorderDA.SaveOrUpdate(entity, OutorderDetailDT, isNew);
        }

        public static bool Del(string strCode)
        {
            return BsOutorderDA.Del(strCode);
        }

        public static DataTable SelectList(string strWorkOrderNo, string  strBackMaterialID, string From, string End, int pageIndex, int PageSize, out int m_count)
        {
            return BsOutorderDA.SelectList(strWorkOrderNo, strBackMaterialID,  From, End, pageIndex, PageSize, out m_count);
        }

        public static DataTable SelectOutProcessDetail(string strScheduleDetailID, string strProcessID)
        {
            return BsOutorderDA.SelectOutProcessDetail(strScheduleDetailID, strProcessID);
        }
       
           public static DataTable SelectListProcessID( string strProcessID,string strWorkOrderNo, int pageIndex, int pageSize,out int  m_count)
        {
            return BsOutorderDA.SelectListProcessID(strProcessID,strWorkOrderNo,pageIndex,pageSize,out m_count);
        }
           public static DataTable SelectHeadData(string strBillID)
           {
               return BsOutorderDA.SelectHeadData(strBillID);
           }
           public static DataTable SelectDetailData(string strBillID)
           {
               return BsOutorderDA.SelectDetailData(strBillID);
           }



          public static DataTable SelectMatCanBackNum(string strCurrentReturnBillID, string sendID, string materialID)
           {
               return BsOutorderDA.SelectMatCanBackNum(strCurrentReturnBillID, sendID, materialID);
           }


          public static DataTable SelectSendDetailCanReturnNum(string strCurrentReturnBillID, string sendID, string materialID)
          {
              return BsOutorderDA.SelectSendDetailCanReturnNum(strCurrentReturnBillID, sendID, materialID);
          }
           public static DataTable CreateDT()
           {
        
            DataTable dt = new DataTable();
            dt.Columns.Add("WorkOrderNo");
            dt.Columns.Add("ScheduleID");
            dt.Columns.Add("ScheduleDetailID");
            dt.Columns.Add("PlanID");
            dt.Columns.Add("ExpectInStockDate");
            dt.Columns.Add("Remark");
            dt.Columns.Add("ProcessID");
            dt.Columns.Add("ProcessName");
          



            dt.Columns.Add("ScheduleNum");//0 
            dt.Columns.Add("IsNew");//是否新增
            dt.Columns.Add("IsDel");//是否删除
            return dt;
     
           }


           public static DataTable CreateDetailDT()
           {


               //   /* bsd.ScheduleDetailID , bsd.WorkOrderNo,bsd.ScheduleID,bsd.PlanID,bsd.ExpectInStockDate, bsd.Remark,
         //bsp.ProcessID,
 
         //bsm.MaterialID, bsm.TotalNum as Nums,bsm.ActulSendDate,bsm.ActulSendNum,
         //m.MaterialTypeID, m.MaterialName, m.Specifications, m.IsDirect, m.Unit,
         //mmt.MaterialTypeName
               //    * /
               DataTable dt = new DataTable();
               //dt.Columns.Add("BillID");
               //dt.Columns.Add("DetailID");
               //dt.Columns.Add("MatType");

               dt.Columns.Add("WorkOrderNo");
               dt.Columns.Add("ScheduleDetailID");
               dt.Columns.Add("PlanID");
               dt.Columns.Add("ExpectInStockDate");
               dt.Columns.Add("Remark");
               dt.Columns.Add("ProcessID");
               dt.Columns.Add("ProcessName");


               dt.Columns.Add("MaterialID");//0 
               dt.Columns.Add("MaterialName");//0 
               dt.Columns.Add("Specifications");//0 
               dt.Columns.Add("IsDirect");//0 
               dt.Columns.Add("Nums",typeof(decimal));//0 
               dt.Columns.Add("Unit");//0 
               dt.Columns.Add("MaterialTypeName", typeof(string));//0

               dt.Columns.Add("IsNew");//是否新增
               dt.Columns.Add("IsDel");//是否删除
               return dt;

           }
    }
}
